package cn.tanglong.shopcart.controller;

import cn.tanglong.basic.exception.MyException;
import cn.tanglong.basic.util.AjaxResult;
import cn.tanglong.shopcart.Dto.ShopCartDto;
import cn.tanglong.shopcart.domain.ShopCart;
import cn.tanglong.shopcart.service.IShopCartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/shopcart")
public class ShopCartController {

    @Autowired
    private IShopCartService shopCartService;

    @PutMapping("/deleteState")
    public AjaxResult deleteState(@RequestBody ShopCart shopCart){
        try {
            ShopCart deleteShopCart = shopCartService.deleteState(shopCart);
            return AjaxResult.me().setResultObj(deleteShopCart);
        } catch (MyException e) {
            e.printStackTrace();
            return AjaxResult.me().setMsg(e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.me().setMsg("接口出错！");
        }
    }
}
